Imports System.Drawing
Imports System.Windows.Forms
Imports Vintasoft.Pdf.Drawing
Imports Vintasoft.Pdf.Tree

Namespace Pdf
	Public Partial Class SelectHighlightForm
		Inherits Form
		Private _pen As PdfPen
		Private _brush As PdfBrush

		Public Sub New(pen As PdfPen)
			InitializeComponent()
			_pen = pen
			propertyGrid.SelectedObject = _pen
			Text = "Pen"
		End Sub

		Public Sub New(brush As PdfBrush)
			InitializeComponent()
			_brush = brush
			propertyGrid.SelectedObject = _brush
			Text = "Brush"
		End Sub

		Public Property ModeIndex() As Integer
			Get
				Return modeComboBox.SelectedIndex
			End Get
			Set
				modeComboBox.SelectedIndex = value
			End Set
		End Property

		Private Sub buttonOk_Click(sender As Object, e As EventArgs)
			DialogResult = DialogResult.OK
		End Sub

		Private Sub buttonCancel_Click(sender As Object, e As EventArgs)
			DialogResult = DialogResult.Cancel
		End Sub

		Private Sub modeComboBox_SelectedIndexChanged(sender As Object, e As EventArgs)
			If modeComboBox.SelectedIndex >= 0 Then
				Dim blendingMode As GraphicsStateBlendMode = GraphicsStateBlendMode.Normal
				Dim blendColor As Color = Color.Black
				Select Case modeComboBox.SelectedIndex
					'Text highlight (yellow)
					Case 0
						blendingMode = GraphicsStateBlendMode.Multiply
						blendColor = Color.Yellow
						Exit Select
					'Text highlight (red)
					Case 1
						blendingMode = GraphicsStateBlendMode.Multiply
						blendColor = Color.Red
						Exit Select
					'Text highlight (green)
					Case 2
						blendingMode = GraphicsStateBlendMode.Multiply
						blendColor = Color.Lime
						Exit Select
					'Invert
					Case 3
						blendingMode = GraphicsStateBlendMode.Difference
						blendColor = Color.White
						Exit Select
					'Soft light
					Case 4
						blendingMode = GraphicsStateBlendMode.SoftLight
						blendColor = Color.White
						Exit Select
					'Soft light (red)
					Case 5
						blendingMode = GraphicsStateBlendMode.SoftLight
						blendColor = Color.Red
						Exit Select
					'Soft light (green)
					Case 6
						blendingMode = GraphicsStateBlendMode.SoftLight
						blendColor = Color.Lime
						Exit Select
					'Soft light (blue)
					Case 7
						blendingMode = GraphicsStateBlendMode.SoftLight
						blendColor = Color.Blue
						Exit Select
					'Hue (red)
					Case 8
						blendingMode = GraphicsStateBlendMode.Hue
						blendColor = Color.Red
						Exit Select
					'Hue (green)
					Case 9
						blendingMode = GraphicsStateBlendMode.Hue
						blendColor = Color.Lime
						Exit Select
					'Hue (blue)
					Case 10
						blendingMode = GraphicsStateBlendMode.Hue
						blendColor = Color.Blue
						Exit Select
				End Select
				If _pen IsNot Nothing Then
					_pen.BlendMode = blendingMode
					_pen.Color = blendColor
					propertyGrid.SelectedObject = _pen
				Else
					_brush.BlendMode = blendingMode
					_brush.Color = blendColor
					propertyGrid.SelectedObject = _brush
				End If
			End If
		End Sub
	End Class
End Namespace
